home *** CD-ROM | disk | FTP | other *** search
- head 1.11;
- branch ;
- access ;
- symbols sprited:1.11.1;
- locks ; strict;
- comment @ * @;
-
-
- 1.11
- date 92.03.25.15.53.12; author shirriff; state Exp;
- branches 1.11.1.1;
- next 1.10;
-
- 1.10
- date 92.01.13.18.08.20; author rab; state Exp;
- branches ;
- next 1.9;
-
- 1.9
- date 91.10.25.15.57.01; author rab; state Exp;
- branches ;
- next 1.8;
-
- 1.8
- date 91.08.26.21.00.46; author rab; state Exp;
- branches ;
- next 1.7;
-
- 1.7
- date 91.08.26.18.11.05; author brent; state Exp;
- branches ;
- next 1.6;
-
- 1.6
- date 89.06.19.14.29.31; author jhh; state Exp;
- branches ;
- next 1.5;
-
- 1.5
- date 88.10.31.09.38.50; author brent; state Exp;
- branches ;
- next 1.4;
-
- 1.4
- date 88.09.12.13.32.19; author brent; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 88.08.07.17.37.10; author ouster; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 88.08.07.15.05.25; author ouster; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.08.07.14.43.03; author ouster; state Exp;
- branches ;
- next ;
-
- 1.11.1.1
- date 92.03.26.17.43.48; author kupfer; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.11
- log
- @Added force mount flag
- @
- text
- @/*
- * prefix.c --
- *
- * Program to print and manipulate the prefix table.
- *
- * Copyright 1988 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/cmds/prefix/RCS/prefix.c,v 1.10 92/01/13 18:08:20 rab Exp Locker: shirriff $ SPRITE (Berkeley)";
- #endif not lint
-
- #include <fs.h>
- #include <fsCmd.h>
- #include <host.h>
- #include <option.h>
- #include <stdio.h>
- #include <string.h>
- #include <status.h>
- #include <sysStats.h>
- #include <sys/stat.h>
-
- static int PrintPrefixEntry _ARGS_ ((Fs_Prefix *prefixPtr));
- static void validateLocalPath _ARGS_ ((char *path, int checkRemote));
-
- extern int errno;
- static char *programName;
-
- /*
- * Command line options.
- */
-
- static int print = 0;
- static int readOnly = 0;
- static int localAccess = 0;
- static int force = 0;
- static char *loadedPrefix = (char *) NULL;
- static char *deviceName = (char *) NULL;
- static char *unmountName = (char *) NULL;
- static char *exportedPrefix = (char *) NULL;
- static char *clearedPrefix = (char *) NULL;
- static char *deletedPrefix = (char *) NULL;
- static char *Prefix = (char *) NULL;
- static char *localPath = (char *) NULL;
- static char *addHostName = NULL;
- static char *delHostName = NULL;
- static char *serverName = NULL;
-
- static Option optionArray[] = {
- {OPT_TRUE, "p", (char *) &print,
- "Print the prefix table or export list"},
- {OPT_STRING, "a", (char *) &loadedPrefix,
- "Next argument is prefix to add"},
- {OPT_STRING, "s", (char *) &serverName,
- "Next argument is name or id of server for added prefix (use with -a)"},
- {OPT_STRING, "l", (char *) &localPath,
- "Next argument is directory to mount/export (with -x, -M or -U)"},
- {OPT_STRING, "M", (char *) &deviceName,
- "Next argument is device to mount (use -l too)"},
- {OPT_TRUE, "r", (char *) &readOnly,
- "Mount read only"},
- {OPT_TRUE, "f", (char *) &force,
- "Force the mount"},
- {OPT_TRUE, "L", (char *) &localAccess,
- "Mount locally only; do not export"},
- {OPT_STRING, "U", (char *) &unmountName,
- "Next argument is prefix to unmount"},
- {OPT_STRING, "x", (char *) &exportedPrefix,
- "Next argument is exported prefix (use with -p, -l, or -[hH])"},
- {OPT_STRING, "h", (char *) &addHostName,
- "Next argument is name or id of host to add to export list"},
- {OPT_STRING, "H", (char *) &delHostName,
- "Next argument is name or id of host to delete from export list"},
- {OPT_STRING, "c", (char *) &clearedPrefix,
- "Next argument is prefix to clear handle for"},
- {OPT_STRING, "d", (char *) &deletedPrefix,
- "Next argument is prefix to delete altogether"},
- };
-
-
-
- /*
- *----------------------------------------------------------------------
- *
- * main --
- *
- * Collects arguments and uses Fs_Command to manipulate the
- * prefix table.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Calls Fs_Command...
- *
- *----------------------------------------------------------------------
- */
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- register ReturnStatus status = SUCCESS; /* status of system calls */
- int flags;
- int addHostID = -1;
- int delHostID = -1;
- int serverID = FS_NO_SERVER;
- Host_Entry *entry;
- int scanned;
- int temp;
-
- programName = argv[0];
- if (argc == 1) {
- print = 1;
- } else {
- argc = Opt_Parse(argc, argv, optionArray, Opt_Number(optionArray),
- OPT_ALLOW_CLUSTERING);
- }
-
- if (argc != 1) {
- fprintf(stderr, "%s got extraneous argument \"%s\".\n", argv[0],
- argv[1]);
- Opt_PrintUsage(argv[0], optionArray, Opt_Number(optionArray));
- exit(1);
- }
- if (addHostName != (char *) NULL) {
- scanned = sscanf(addHostName, " %d", &temp);
- if (scanned == 1) {
- addHostID = temp;
- } else {
- entry = Host_ByName(addHostName);
- if (entry == NULL) {
- fprintf(stderr, "No such host \"%s\"\n", addHostName);
- exit(1);
- }
- addHostID = entry->id;
- }
- }
- if (delHostName != (char *) NULL) {
- scanned = sscanf(delHostName, " %d", &temp);
- if (scanned == 1) {
- delHostID = temp;
- } else {
- entry = Host_ByName(delHostName);
- if (entry == NULL) {
- fprintf(stderr, "No such host \"%s\"\n", delHostName);
- exit(1);
- }
- delHostID = entry->id;
- }
- }
- if (serverName != (char *) NULL) {
- scanned = sscanf(serverName, " %d", &temp);
- if (scanned == 1) {
- serverID = temp;
- } else {
- entry = Host_ByName(serverName);
- if (entry == NULL) {
- fprintf(stderr, "No such host \"%s\"\n", serverName);
- exit(1);
- }
- serverID = entry->id;
- }
- }
- if (loadedPrefix != (char *) NULL) {
- /*
- * Load a prefix
- * Load a prefix into the prefix table.
- * A prefix in the prefix table causes an attempt to find the
- * server the first time a file is opened under that prefix.
- * If serverID == FS_NO_SERVER then a broadcast is done,
- * otherwise the server is contacted directly.
- */
- Fs_PrefixLoadInfo loadInfo;
-
- (void) strcpy(loadInfo.prefix, loadedPrefix);
- loadInfo.serverID = serverID;
- status = Fs_Command(FS_PREFIX_LOAD, sizeof(Fs_PrefixLoadInfo),
- &loadInfo);
- if (status != SUCCESS) {
- fprintf(stderr, "%s couldn't load prefix: %s.\n",
- argv[0], Stat_GetMsg(status));
- exit(1);
- }
- }
- if (deviceName != (char *)NULL) {
- if (!force) {
- validateLocalPath(localPath, 1);
- }
- flags = 0;
- if (localAccess) {
- flags |= FS_ATTACH_LOCAL;
- }
- if (readOnly) {
- flags |= FS_ATTACH_READ_ONLY;
- }
- status = Fs_AttachDisk(deviceName, localPath, flags);
- if (status != SUCCESS) {
- fprintf(stderr, "Mount \"%s\" on \"%s\": %s\n", deviceName,
- localPath, Stat_GetMsg(status));
- exit(1);
- }
- localPath = (char *)NULL;
- }
- if (unmountName != (char *)NULL) {
- status = Fs_AttachDisk(deviceName, unmountName, FS_DETACH);
- if (status != SUCCESS) {
- fprintf(stderr, "Unmount \"%s\": %s\n", unmountName,
- Stat_GetMsg(status));
- exit(1);
- }
- }
- if (addHostID != -1 || delHostID != -1) {
- Fs_PrefixControl prefixControl;
- /*
- * Add or remove a host from a prefix's export list.
- */
- if (exportedPrefix == (char *) NULL) {
- fprintf(stderr, "Specify an exported prefix with -x\n");
- Opt_PrintUsage(argv[0], optionArray, Opt_Number(optionArray));
- exit(1);
- }
- if (addHostID != -1) {
- prefixControl.clientID = addHostID;
- prefixControl.delete = FALSE;
- } else {
- prefixControl.clientID = delHostID;
- prefixControl.delete = TRUE;
- }
- (void) strcpy(prefixControl.prefix, exportedPrefix);
- status = Fs_Command(FS_PREFIX_CONTROL, sizeof(prefixControl),
- &prefixControl);
- if (status != SUCCESS) {
- fprintf(stderr, "%s couldn't add/delete host: %s.\n",
- argv[0], Stat_GetMsg(status));
- exit(1);
- }
- exportedPrefix = (char *) NULL;
- }
- if (exportedPrefix != (char *) NULL) {
- if (print) {
- /*
- * Print the export list of this prefix.
- */
- char buffer[100 * sizeof(int)];
- int *exportList = (int *)buffer;
- (void) strcpy(buffer, exportedPrefix);
- status = Sys_Stats(SYS_FS_PREFIX_EXPORT, sizeof(buffer), buffer);
- if (status != SUCCESS) {
- fprintf(stderr, "%s: couldn't get export list\n",
- exportedPrefix);
- exit(status);
- } else if (*exportList == 0) {
- printf("%s exported to all hosts\n", exportedPrefix);
- } else {
- printf("\"%s\" EXPORT LIST\n", exportedPrefix);
- for ( ; *exportList != 0 ; exportList++) {
- Host_Entry *hostPtr;
- hostPtr = Host_ByID(*exportList);
- if (hostPtr == (Host_Entry *)NULL) {
- break;
- }
- printf("\t<%d> %s\n", hostPtr->id, hostPtr->name);
- }
- }
- } else {
- Fs_TwoPaths args;
-
- /*
- * localPath may be "/", a real directory, when the
- * -x option is used so disable the remote link check
- * in validateLocalPath
- */
- if (!force) {
- validateLocalPath(localPath, 0);
- }
-
- /*
- * Export a prefix. This is used on a server to explicitly
- * export a local directory under some prefix.
- */
-
- args.pathLen1 = strlen(localPath) + 1;
- args.path1 = localPath;
- args.pathLen2 = strlen(exportedPrefix) + 1;
- args.path2 = exportedPrefix;
-
- status = Fs_Command(FS_PREFIX_EXPORT, sizeof(Fs_TwoPaths), &args);
- if (status != SUCCESS) {
- fprintf(stderr, "%s couldn't export prefix: %s.\n",
- argv[0], Stat_GetMsg(status));
- exit(1);
- }
- }
- }
- if (clearedPrefix != (char *) NULL) {
- /*
- * Clear a prefix's file handle.
- */
- status = Fs_Command(FS_PREFIX_CLEAR, strlen(clearedPrefix) + 1,
- clearedPrefix);
- if (status != SUCCESS) {
- fprintf(stderr, "%s couldn't clear prefix handle: %s.\n",
- argv[0], Stat_GetMsg(status));
- exit(1);
- }
- }
- if (deletedPrefix != (char *) NULL) {
- /*
- * Delete a prefix
- */
- status = Fs_Command(FS_PREFIX_DELETE, strlen(deletedPrefix) + 1,
- deletedPrefix);
- if (status != SUCCESS) {
- fprintf(stderr, "%s couldn't delete prefix: %s.\n",
- argv[0], Stat_GetMsg(status));
- exit(1);
- }
- }
- if (print) {
- register int index;
- Fs_Prefix prefix;
-
- printf("%-20s %-8s %7s %7s %8s\n",
- "Prefix", "Server", "Domain", "File #", "Version");
- for (index = 0 ; status == SUCCESS; index++) {
- bzero((char *) &prefix, sizeof(Fs_Prefix));
- status = Sys_Stats(SYS_FS_PREFIX_STATS, index, (Address) &prefix);
- if (status == SUCCESS) {
- PrintPrefixEntry(&prefix);
- }
- }
- }
- exit(0);
- }
-
- /*
- *----------------------------------------------------------------------
- *
- * PrintPrefixEntry --
- *
- * Print out information for a single prefix table entry.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Stuff gets printed.
- *
- *----------------------------------------------------------------------
- */
-
- static int
- PrintPrefixEntry(prefixPtr)
- Fs_Prefix *prefixPtr;
- {
- static char serverName[9];
- static int prevServerID = -1;
- Host_Entry *host;
-
- printf("%-20s", prefixPtr->prefix);
-
- if (prefixPtr->serverID > 0) {
-
- /*
- * If the server ID is the same as the previous entry's ID, then
- * we can reuse serverName and save a call to Host_ByID.
- */
- if (prefixPtr->serverID == prevServerID) {
- printf(" %-8s", serverName);
- } else {
- host = Host_ByID(prefixPtr->serverID);
- if (host != (Host_Entry *)NULL) {
- register int charCnt;
- for (charCnt = 0 ; charCnt < sizeof(serverName) ; charCnt++) {
- if (host->name[charCnt] == '.' ||
- host->name[charCnt] == '\0') {
- serverName[charCnt] = '\0';
- break;
- } else {
- serverName[charCnt] = host->name[charCnt];
- }
- }
- serverName[sizeof(serverName)-1] = '\0';
- printf(" %-8s", serverName);
- prevServerID = prefixPtr->serverID;
- } else {
- printf(" (%d)", prefixPtr->serverID);
- }
- }
- } else {
- printf(" %-8s", "(none)");
- }
-
- printf(" %7d %7d %8d", prefixPtr->domain, prefixPtr->fileNumber,
- prefixPtr->version);
-
- if (prefixPtr->flags & FS_LOCAL_PREFIX) {
- printf(" local ");
- }
- if (prefixPtr->flags & FS_IMPORTED_PREFIX) {
- printf(" imported");
- }
- if (prefixPtr->flags & FS_EXPORTED_PREFIX) {
- printf(" exported");
- }
- printf("\n");
- }
-
- /*
- *----------------------------------------------------------------------
- *
- * validateLocalPath --
- *
- * Make sure the local path specified with the -l option is valid.
- * It must be an absolute path starting with '/'.
- * It must be an already existing remote link if checkRemote == 1.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Will exit with an error code of 1 if the path is invalid.
- *
- *----------------------------------------------------------------------
- */
-
- static void
- validateLocalPath(path, checkRemote)
- char *path;
- int checkRemote;
- {
- struct stat statBuf;
-
- if (path == NULL) {
- fprintf(stderr, "%s: You must specify a local directory with -l\n",
- programName);
- Opt_PrintUsage(programName, optionArray, Opt_Number(optionArray));
- exit(1);
- } else if (*path != '/') {
- fprintf(stderr,
- "%s: %s is not an absolute path. It must start with '/'\n",
- programName, path);
- exit(1);
- }
- if (lstat(path, &statBuf) < 0) {
- fprintf(stderr, "%s: Cannot lstat %s: %s\n",
- programName, path, strerror(errno));
- exit(1);
- }
- if (checkRemote && (statBuf.st_mode & S_IFMT) != S_IFRLNK) {
- fprintf(stderr, "%s: %s is not a remote link.\n",
- programName, path);
- exit(1);
- }
- return;
- }
-
- @
-
-
- 1.11.1.1
- log
- @Initial branch for Sprite server.
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: /sprite/src/cmds/prefix/RCS/prefix.c,v 1.11 92/03/25 15:53:12 shirriff Exp $ SPRITE (Berkeley)";
- @
-
-
- 1.10
- log
- @localPath doesn't have to be a remote link with -x option
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: /sprite/src/cmds/prefix/RCS/prefix.c,v 1.9 91/10/25 15:57:01 rab Exp Locker: rab $ SPRITE (Berkeley)";
- d43 1
- d69 2
- d194 3
- a196 1
- validateLocalPath(localPath, 1);
- d281 3
- a283 1
- validateLocalPath(localPath, 0);
- @
-
-
- 1.9
- log
- @lstat the link to make sure it exists before adding it.
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: /sprite/src/cmds/prefix/RCS/prefix.c,v 1.8 91/08/26 21:00:46 rab Exp Locker: rab $ SPRITE (Berkeley)";
- d31 1
- a31 1
- static void validateLocalPath _ARGS_ ((char *path));
- d191 1
- a191 1
- validateLocalPath(localPath);
- d271 6
- a276 1
- validateLocalPath(localPath);
- d417 1
- a417 1
- * It must be an already existing remote link.
- d429 1
- a429 1
- validateLocalPath(path)
- d431 1
- d451 1
- a451 1
- if ((statBuf.st_mode & S_IFMT) != S_IFRLNK) {
- @
-
-
- 1.8
- log
- @Ensure that if the -l option is used, it must specify an absolute path
- to an existing remote link.
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: /sprite/src/cmds/prefix/RCS/prefix.c,v 1.7 91/08/26 18:11:05 brent Exp Locker: rab $ SPRITE (Berkeley)";
- d429 3
- a431 2
- if (path == (char *) NULL) {
- fprintf(stderr, "You must specify a local directory with -l\n");
- d436 2
- a437 1
- "%s is not an absolute path. It must start with '/'\n", path);
- d440 3
- a442 2
- if (stat(path, &statBuf) < 0) {
- fprintf(stderr, "Cannot stat %s: %s\n", path, strerror(errno));
- d446 2
- a447 1
- fprintf(stderr, "%s is not a remote link.\n", localPath);
- @
-
-
- 1.7
- log
- @*** empty log message ***
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: /a/newcmds/prefix/RCS/prefix.c,v 1.6 89/06/19 14:29:31 jhh Exp $ SPRITE (Berkeley)";
- d28 1
- d30 6
- d40 14
- a53 14
- int print = 0;
- int readOnly = 0;
- int localAccess = 0;
- char *loadedPrefix = (char *) NULL;
- char *deviceName = (char *) NULL;
- char *unmountName = (char *) NULL;
- char *exportedPrefix = (char *) NULL;
- char *clearedPrefix = (char *) NULL;
- char *deletedPrefix = (char *) NULL;
- char *Prefix = (char *) NULL;
- char *localPath = (char *) NULL;
- char *addHostName = NULL;
- char *delHostName = NULL;
- char *serverName = NULL;
- d55 1
- a55 1
- Option optionArray[] = {
- d83 2
- d116 1
- d191 1
- a191 5
- if (localPath == (char *)NULL) {
- fprintf(stderr, "Need -l {local directory} with -M\n");
- Opt_PrintUsage(argv[0], optionArray, Opt_Number(optionArray));
- exit(1);
- }
- a267 4
- } else if (localPath == (char *) NULL) {
- fprintf(stderr, "Also specify a local directory with -l\n");
- Opt_PrintUsage(argv[0], optionArray, Opt_Number(optionArray));
- exit(1);
- d270 3
- a272 1
-
- d348 1
- d350 1
- a350 1
- register Fs_Prefix *prefixPtr;
- d404 45
- @
-
-
- 1.6
- log
- @added -s option, also changed -[hH] to use names as well as ids.
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: /a/newcmds/prefix/RCS/prefix.c,v 1.5 88/10/31 09:38:50 brent Exp Locker: jhh $ SPRITE (Berkeley)";
- a207 1
- clearedPrefix = unmountName;
- @
-
-
- 1.5
- log
- @Added in attachDisk functionality
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: /a/newcmds/prefix/RCS/prefix.c,v 1.4 88/09/12 13:32:19 brent Exp Locker: brent $ SPRITE (Berkeley)";
- d44 3
- a46 2
- int addHostID = -1;
- int delHostID = -1;
- d53 2
- d67 4
- a70 4
- {OPT_INT, "h", (char *) &addHostID,
- "Next argument is host to add to export list"},
- {OPT_INT, "H", (char *) &delHostID,
- "Next argument is host to delete from export list"},
- d98 8
- a105 2
- register ReturnStatus status = SUCCESS; /* status of system calls */
- int flags;
- d120 39
- a158 1
-
- d163 1
- a163 1
- * A prefix in the prefix table causes a broadcast to find the
- d165 2
- d168 6
- a173 2
- status = Fs_Command(FS_PREFIX_LOAD, strlen(loadedPrefix) + 1,
- loadedPrefix);
- d182 1
- a182 1
- fprintf(stderr, "%s: need -l {local directory} with -M\n");
- @
-
-
- 1.4
- log
- @Added printing of export lists
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: prefix.c,v 1.3 88/08/07 17:37:10 ouster Exp $ SPRITE (Berkeley)";
- d34 2
- d37 2
- d48 24
- a71 8
- {OPT_TRUE, "p", (char *) &print, "Print the prefix table or export list"},
- {OPT_STRING, "a", (char *) &loadedPrefix, "Next argument contains prefix to add"},
- {OPT_STRING, "l", (char *) &localPath, "Next argument contains directory to export (use with -x)"},
- {OPT_STRING, "x", (char *) &exportedPrefix, "Next argument contains exported prefix (use with -p, -l, or -[hH])"},
- {OPT_INT, "h", (char *) &addHostID, "Next argument contains host to add to export list"},
- {OPT_INT, "H", (char *) &delHostID, "Next argument contains host to delete from export list"},
- {OPT_STRING, "c", (char *) &clearedPrefix, "Next argument contains prefix to clear handle for"},
- {OPT_STRING, "d", (char *) &deletedPrefix, "Next argument contains prefix to delete altogether"},
- d96 1
- d108 1
- a108 1
- fprintf(stderr, "Type \"%s -help\" for help.\n", argv[0]);
- d127 30
- d159 3
- a161 1
-
- a233 4
- } else if (localPath != (char *) NULL) {
- fprintf(stderr, "Also specify an exported prefix with -x\n");
- Opt_PrintUsage(argv[0], optionArray, Opt_Number(optionArray));
- exit(1);
- @
-
-
- 1.3
- log
- @Eliminated "-D" switch, since it's embodied in df now.
- @
- text
- @d4 1
- a4 1
- * Program to manipulate the prefix table.
- d17 1
- a17 1
- static char rcsid[] = "$Header: prefix.c,v 1.1 88/08/07 14:43:03 ouster Exp $ SPRITE (Berkeley)";
- d38 1
- d44 1
- a44 1
- {OPT_TRUE, "p", (char *) &print, "Print the prefix table"},
- d47 1
- a47 1
- {OPT_STRING, "x", (char *) &exportedPrefix, "Next argument contains name of xported prefix (use with -l or -[hH])"},
- d132 27
- a158 4
- Fs_TwoPaths args;
-
- if (localPath == (char *) NULL) {
- fprintf(stderr, "Specify a local directory with -l\n");
- d161 19
- a180 17
-
- /*
- * Export a prefix. This is used on a server to explicitly
- * export a local directory under some prefix.
- */
-
- args.pathLen1 = strlen(localPath) + 1;
- args.path1 = localPath;
- args.pathLen2 = strlen(exportedPrefix) + 1;
- args.path2 = exportedPrefix;
-
- status = Fs_Command(FS_PREFIX_EXPORT, sizeof(Fs_TwoPaths), &args);
- if (status != SUCCESS) {
- fprintf(stderr, "%s couldn't export prefix: %s.\n",
- argv[0], Stat_GetMsg(status));
- exit(1);
- }
- d182 1
- a182 1
- fprintf(stderr, "Specify an exported prefix with -x\n");
- @
-
-
- 1.2
- log
- @Handle "df" alias.
- @
- text
- @a33 1
- int diskInfo = 0;
- a43 2
- {OPT_TRUE, "D", (char *) &diskInfo,
- "Print out disk space information about all domains"},
- a74 1
- char *p;
- d76 2
- a77 7
- /*
- * If invoked under the name "df", just print disk utilization info.
- */
-
- p = strrchr(argv[0], '/');
- if (p == NULL) {
- p = argv[0];
- d79 2
- a80 1
- p += 1;
- a81 10
- if (strcmp(p, "df") == 0) {
- diskInfo = 1;
- } else {
- if (argc == 1) {
- print = 1;
- } else {
- argc = Opt_Parse(argc, argv, optionArray, Opt_Number(optionArray),
- OPT_ALLOW_CLUSTERING);
- }
- }
- a196 13
- } else if (diskInfo) {
- register int index;
- Fs_Prefix prefix;
-
- printf("%-12s %-8s %10s %10s %10s %10s\n",
- "Prefix", "Server", "KBytes", "Used", "Avail", "Capacity");
- for (index = 0 ; status == SUCCESS; index++) {
- bzero((char *) &prefix, sizeof(Fs_Prefix));
- status = Sys_Stats(SYS_FS_PREFIX_STATS, index, (Address)&prefix);
- if (status == SUCCESS) {
- PrintDiskInfo(&prefix);
- }
- }
- d200 16
- a270 58
- }
-
- PrintDiskInfo(prefixPtr)
- register Fs_Prefix *prefixPtr;
- {
- static char serverName[32];
- static int prevServerID = -1;
- int inUse;
- int free;
- int avail;
- Host_Entry *host;
-
- printf("%-12s", prefixPtr->prefix);
-
- if (prefixPtr->serverID > 0) {
-
- /*
- * If the server ID is the same as the previous entry's ID, then
- * we can reuse serverName and save a call to Host_ByID.
- */
- if (prefixPtr->serverID == prevServerID) {
- printf(" %-8s", serverName);
- } else {
- host = Host_ByID(prefixPtr->serverID);
- if (host != (Host_Entry *)NULL) {
- register int charCnt;
- for (charCnt = 0 ; charCnt < sizeof(serverName) ; charCnt++) {
- if (host->name[charCnt] == '.' ||
- host->name[charCnt] == '\0') {
- serverName[charCnt] = '\0';
- break;
- } else {
- serverName[charCnt] = host->name[charCnt];
- }
- }
- serverName[sizeof(serverName)-1] = '\0';
- printf(" %-8s", serverName);
- prevServerID = prefixPtr->serverID;
- } else {
- printf(" (%d)", prefixPtr->serverID);
- }
- }
- } else {
- printf(" %-8s", "(none)");
- }
- if (prefixPtr->domainInfo.maxKbytes <= 0) {
- printf("\n");
- return;
- }
-
- free = prefixPtr->domainInfo.freeKbytes -
- (0.1 * prefixPtr->domainInfo.maxKbytes);
- avail = 0.9 * prefixPtr->domainInfo.maxKbytes;
- inUse = avail - free;
-
- printf(" %10d %10d %10d %7d%%\n",
- prefixPtr->domainInfo.maxKbytes, inUse, free >= 0 ? free : 0,
- (int) (100.0 * (inUse / (float) avail)));
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: prefix.c,v 1.11 88/07/13 11:45:41 nelson Exp $ SPRITE (Berkeley)";
- d78 1
- d80 7
- a86 2
- if (argc == 1) {
- print = TRUE;
- d88 11
- a98 2
- argc = Opt_Parse(argc, argv, optionArray, Opt_Number(optionArray),
- OPT_ALLOW_CLUSTERING);
- @
-